<?php include('functions.php'); ?>
<html>
<head>
<title>oPanel V<?php echo $ver; ?></title>
<link rel="shortcut icon" href="favicon.ico" />
<link rel="stylesheet"href="style.css">
</head>
<body>
<?php
include($_SESSION["trashfile"]);

$file = $_GET['file'];

if (isset($file)) {

$var1 = explode(".", $file);// old strrchr($file,'.');
if($var1[0] != "") {
$var = str_replace(" ", "_", $var1[0]);
} else {
$var = str_replace(" ", "_", $var1[1]);
}
$dir = addslashes($$var);
   if (!$handle = fopen($_SESSION["trashfile"], 'a+')) {

         die("Cannot open file ($filename)");
         exit;
   }
   if (!isset($$var)) {
       die("The file has not been deleted ($file)");
       exit;
   }

}
if (rename("$_SESSION[trashdir]$file", "".$$var."/".$file."") === TRUE) {
echo "$file was restored!";

   fclose($handle);
}
$lines = file("$_SESSION[trashfile]");
$i = 0;
foreach ($lines as $line_num => $linee) {
$line = preg_replace('/\n/', '', $linee);
$hobla = str_replace("<?php $".$var." = '".$dir."'; ?>", "", "".$line."");
if($i == 0) {
if (is_writable($_SESSION["trashfile"])) {
   if (!$handle = fopen($_SESSION["trashfile"], 'w+')) {
         die("Cannot open file ($filename)");
         exit;
   }
   if (fwrite($handle, $hobla) === FALSE) {
       die("Cannot write to a needed file ($filename)");
       exit;
   }  
   fclose($handle);
} else {
   die("a needed file is not writable ($_SESSION[trashfile])");
}
} else {
if (is_writable($_SESSION["trashfile"])) {
   if (!$handle = fopen($_SESSION["trashfile"], 'a+')) {
         die("Cannot open file ($filename)");
         exit;
   }
   if (fwrite($handle, $hobla) === FALSE) {
       die("Cannot write to a needed file ($filename)");
       exit;
   }  
   fclose($handle);
} else {
   die("a needed file is not writable ($_SESSION[trashfile])");
}
}
$i++;
}
?>
<script>
<!--
function wait(delay){
string="pauseforalert();";
setTimeout(string,delay);
}
function pauseforalert(){
alert("oPanel will now refresh to update...");
parent.filemain.location="http://<?php echo $_SERVER["HTTP_HOST"]; echo dirname("$_SERVER[SCRIPT_NAME]"); ?>/list.php?dir=<?php echo $dir; ?>";
parent.trashframe.location="http://<?php echo $_SERVER["HTTP_HOST"]; echo dirname("$_SERVER[SCRIPT_NAME]"); ?>/trash.php";
}
// -->
</script>
<script type="text/javascript">
wait(1000)
</script>
</body>
</html>